jQuery(document).ready(function($){ var has_remove=function(){ $('.highlight-and-share-wrapper:visible').remove(); $('.has_sharing_email').css('display', 'none'); }; var title=''; var link=''; var href=''; var $parent=''; var has_selected_text=''; var text_to_copy=false; var has_load_html=function(){ var html='
'; $('body').append(inline_share); $('body').append(click_to_share); $('body').append(html); }; var js_content=highlight_and_share.content; if(''==js_content) return; $('body').on('mouseup vmouseup', js_content, function(e){ e.stopPropagation(); has_remove(); var selection=window.getSelection(); var text=selection.toString(); this.title=''; if(''==text){ return; } $parent=$(e.target).parent('.has-content-area'); this.href=$parent.data('url'); if(typeof this.href==typeof undefined||this.href==false){ this.href=$(location).attr('href'); } this.title=$parent.data('title'); if(typeof this.title==typeof undefined||this.title==false){ this.title=$(document).attr('title'); } has_display(text, this.title, this.href, e); }); $('body').on('click', '.has-click-prompt', function(e){ e.preventDefault(); var $target=jQuery(e.target); var text=$target.siblings('.has-click-to-share-text').text().trim(); text_to_copy=text; cts_display(text, $target.data('title'), $target.data('url'), e); }); $('body').on('click', '.has-inline-text', function(e){ e.preventDefault(); if($('.highlight-and-share-wrapper-inline').is(':visible')){ has_remove(); return; } $parent=$(e.target).parents('.has-content-area'); var href=$parent.data('url'); if(typeof href==typeof undefined||href==false){ href=$(location).attr('href'); } var title=$parent.data('title'); if(typeof title==typeof undefined||title==false){ title=$(document).attr('title'); } var text=jQuery(this).text().trim(); inline_has_display(text, title, href, e); }); $('body').on('mousedown vmousedown', function(e){ has_get_selection(); }); document.addEventListener("selectionchange", function(){ has_get_selection(); }, false); $('body').on('click', '.has_twitter a:visible', function(e){ e.preventDefault(); if(highlight_and_share.customizer_preview){ return; } this.href=this.href.replace('%text%', encodeURIComponent(has_selected_text)); window.open(this.href,"tweethighlight","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); has_remove(); return false; }); $('body').on('click', '.has_facebook a:visible', function(e){ e.preventDefault(); if(highlight_and_share.customizer_preview){ return; } this.href=this.href.replace('%text%', encodeURIComponent(has_selected_text)); window.open(this.href,"sharer","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); has_remove(); }); $('body').on('click', '.has_linkedin a:visible', function(e){ e.preventDefault(); if(highlight_and_share.customizer_preview){ return; } window.open(this.href,"linkedin","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); has_remove(); }); $('body').on('click', '.has_pinterest a:visible', function(e){ e.preventDefault(); if(highlight_and_share.customizer_preview){ return; } window.open(this.href,"pinterest","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); has_remove(); }); $('body').on('click', '.has_xing a:visible', function(e){ e.preventDefault(); if(highlight_and_share.customizer_preview){ return; } window.open(this.href,"xing","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); has_remove(); }); $('body').on('click', '.has_whatsapp a:visible', function(e){ e.preventDefault(); if(highlight_and_share.customizer_preview){ return; } this.href=this.href.replace('%text%', encodeURIComponent(has_selected_text)); window.open(this.href,"whatsapp","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); has_remove(); }); $('body').on('click', '.has_copy a:visible', function(e){ e.preventDefault(); if(false==text_to_copy){ document.execCommand ("copy"); }else{ const el=document.createElement('textarea'); el.value=text_to_copy; document.body.appendChild(el); el.select(); document.execCommand ('copy'); document.body.removeChild(el); } has_remove(); }) $('body').on('click', '.has_email a:visible', function(e){ e.preventDefault(); if(highlight_and_share.customizer_preview){ return; } if($parent){ var data_href=decodeURIComponent($parent.data('url')); var data_title=decodeURIComponent($parent.data('title')); }else{ var data_href='undefined'; var data_title='undefined'; } if('undefined'===data_title){ data_title=window.document.title; } if('undefined'===data_href){ data_href=window.location.href; } var subject=highlight_and_share.email_subject_text; subject=subject.replace('%title%', data_title); var html=''; html +='